package com.briup.cms.dao;


import com.briup.cms.bean.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Results({
           @Result(column = "comment_date",property = "commentDate"),
            @Result(column = "article_id",property = "articleId"),
            @Result(column = "user_id",property = "userId"),
            @Result(column = "parent_id",property = "parentId")

    }

    )
    @Select("select * from comment")
    List<Comment> selectAll();

    @Insert("insert into comment values(null,#{content},#{commentDate},#{status},#{articleId},#{userId},#{parentId})")
    void insert(Comment comment);

    @Update("update comment set content=#{content},comment_date=#{commentDate},status=#{status},article_id=#{articleId},user_id=#{userId},parent_id=#{parentId} where id=#{id}")
    void update(Comment comment);

    @Delete("delete from comment where id=#{id}")
    void deleteById(long id);
}
